(function($){

	/**
	 * 默认配置修改
	 */
	
	$.extend($.messager.defaults,{ok:"是",cancel:"否"});
	$.extend($.fn.datagrid.defaults,{loadMsg:"正在导入,请稍等...",pageSize:20,fit:true,pagination:true,singleSelect:true});
	$.extend($.fn.pagination.defaults,{afterPageText: "页    共 {pages} 页",beforePageText: "页",displayMsg: "当前显示 {from} - {to} 条记录   共 {total} 条记录"});
	
	/**
	 * 日期格式工具
	 */
	
	$.formatDate = function(date,format) {
		/*
		 * format="yyyy-MM-dd hh:mm:ss";
		 */
		var o = {
				"M+" : date.getMonth() + 1,
				"d+" : date.getDate(),
				"h+" : date.getHours(),
				"m+" : date.getMinutes(),
				"s+" : date.getSeconds(),
				"q+" : Math.floor((date.getMonth() + 3) / 3),
				"S" : date.getMilliseconds()
		}
		
		if (/(y+)/.test(format)) {
			format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
		}
		for ( var k in o) {
			if (new RegExp("(" + k + ")").test(format)) {
				format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]: ("00" + o[k]).substr(("" + o[k]).length));
			}
		}
		return format;
	};
	
	
	$.formtoJson = function(ele){
		
		var arr = ele.serializeArray();
		
		
		 var jsonStr = "";
		 
           jsonStr += '{';
           for (var i = 0; i < arr.length; i++) {
               jsonStr += '"' + arr[i].name + '":"' + arr[i].value + '",'
           }
           jsonStr = jsonStr.substring(0, (jsonStr.length - 1));
           jsonStr += '}';

           var json = JSON.parse(jsonStr);
           return json;
	};
	
	$.bringBack = function(data){
		var lp = data.lookup;
		var alp = $("[lookupGroup='"+lp+"']");
		eval(" var "+lp+" = data ");
		var fi = alp.find("input[toName]");
		fi.each(function(index,ele){
			var toName = $(this).attr("toName");
			$(this).val(eval(toName));
			
		});
		
		
		
		
		
		
	};
	

	
})(jQuery);
function formatterTime(value, row, index)
{
	var t = $.formatDate(new Date(value),"yyyy-MM-dd hh:mm:ss");
	return t;
}

